package sinpleFactory.order;

import sinpleFactory.pizza.CheesePizza;
import sinpleFactory.pizza.GreekPizza;
import sinpleFactory.pizza.PepperPizza;
import sinpleFactory.pizza.Pizza;

/**
 * @author feng
 * @Date 2021/10/14 17:30
 *  简单工厂模式(静态工厂模式)
 */
public class SimpleFactory2 {

    public static Pizza createPizza(String orderType) {
        Pizza pizza = null;
        System.out.println("使用简单工厂模式创建");
        if (orderType.equals("greek")) {
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        } else if (orderType.equals("cheese")) {
            pizza = new CheesePizza();
            pizza.setName("Cheese披萨");
        }else if (orderType.equals("pepper")){
            pizza = new PepperPizza();
            pizza.setName("Pepper披萨");
        }
        return pizza;
    }


}
